package cn.czk.demo;

import dev.langchain4j.data.message.AiMessage;
import dev.langchain4j.data.message.ChatMessage;
import dev.langchain4j.data.message.Content;
import dev.langchain4j.data.message.UserMessage;
import dev.langchain4j.model.openai.OpenAiChatModel;
import dev.langchain4j.model.output.Response;

import java.util.ArrayList;
import java.util.List;


public class HelloWord {

    public static void main(String[] args) {

        OpenAiChatModel model = OpenAiChatModel.builder()
                .apiKey("53e452feb1164ec8a6c9cd9112a37d60.xTOwz9t4NIZuYTYb")
                .modelName("glm-4")
                .baseUrl("https://open.bigmodel.cn/api/paas/v4/")
                .temperature(0.95)
                .build();
        UserMessage userMessage1 = UserMessage.userMessage("你是谁");

        Response<AiMessage> response1 = model.generate(userMessage1);
        AiMessage aiMessage1 = response1.content();
        System.out.println(aiMessage1.text());

        UserMessage userMessage2 = UserMessage.userMessage("你刚才说了什么");
        Response<AiMessage> response2 = model.generate(userMessage1, aiMessage1, userMessage2);
        AiMessage aiMessage2 = response2.content();
        System.out.println(aiMessage2.text());

    }

}
